import time

from selenium.webdriver.common.by import By
from selenium import webdriver
from Pozk0903.Base import Base

class Page2(Base):
    #点击去登录
    login_loc=(By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]')
    def login(self):
        self.click(self.login_loc)
    # 断言
    dy_loc = (By.XPATH, '/html/body/div/form/div/div/div/div/div[1]/div[1]/a[1]')
    def dy1(self):
        self.text(self.dy_loc)
    #输入账号密码
    user_loc=(By.NAME,'uname')
    def username(self):
        self.send_keys(self.user_loc,'13381144084')
    pass_loc=(By.ID,'password')
    def password(self):
        self.send_keys(self.pass_loc,'grq200566++')
    # 点击登录按钮
    an_loc = (By.ID, 'save')
    def anniu(self):
        self.click(self.an_loc)
    #点击输入框输入内容
    srk_loc=(By.ID,'wd')
    def srk(self):
        self.send_keys(self.srk_loc,'五粮液')
    #点击搜索按钮
    ss_loc=(By.XPATH,'/html/body/div[4]/div/div[2]/div[1]/form/input[2]')
    def ss(self):
        self.click(self.ss_loc)
    #点击商品
    sp_loc=(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')
    def sp(self):
        self.click(self.sp_loc)
    #点击购物车
    sc_loc=(By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[3]/div[2]/div[1]/a/i')
    def sc(self):
        self.click(self.sc_loc)

    def jiuxian_luoji_sc(self):
        self.open_url('https://www.jiuxian.com/')
        self.login()
        # assert '登录' in self.dy1()
        self.username()
        self.password()
        time.sleep(10)
        self.anniu()
        time.sleep(5)
        self.srk()
        self.ss()
        time.sleep(4)
        self.sp()
        self.window()
        self.sc()
